<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String BASE_PATH = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>搜索查询</title>
    <link rel="stylesheet" href="${BASE_PATH}static/css/commen.css"/>
    <link rel="stylesheet" href="${BASE_PATH}static/css/SuperSlide.css"/>
    <link rel="stylesheet" href="${BASE_PATH}static/css/public.css">
    <link rel="stylesheet" href="${BASE_PATH}static/css/search.css">
    <link rel="stylesheet" href="${BASE_PATH}static/css/jujiao.css">
</head>
<body>
<div class="g_coun_head">
    <form action="" method="post">
        <div class="g_coun_head_main clearfix">
            <a class="g_c_h_m_logo fl" href="${BASE_PATH}index.jsp"></a>
            <ul class="g_c_h_m_lists fl">
                <li class="active"><a href="${BASE_PATH}index.jsp">首页</a></li>
                <li><a href="${BASE_PATH}businessRisk.jsp">企业风险榜单</a></li>
                <li><a href="${BASE_PATH}focus.jsp">企业风险聚焦</a></li>
            </ul>
            <div class="g_c_h_m_user fr">
                <a href="" class="g_c_h_m_login fl">登录</a>
                <a href="" class="g_c_h_m_registe fl active">免费注册</a>
            </div>
        </div>
    </form>
    <p class="g_coun_h_shandow"></p>
</div>
<div class="sear_contain">
    <div class="sear_con_left fl">
        <div class="sear_conL_sear">
            <div class="sear_conL_searInput">
                <input type="text" class="sear_conL_searInpTex fl" id="sear_conL_searInpTex" placeholder="小米科技">
                <input type="button" class="sear_conL_searInpBtn fl" value="查处罚" onclick="searchX(1)">
            </div>
            <div class="sear_conL_searCond">
                <div class="sear_conL_searCond_tit">
                    <span class="sear_conL_searCond_titL fl">
                        <span class="icon-sear_intell fl"></span>
                        <span>智能筛选</span>
                    </span>
                    <span class="sear_conL_searCond_titR fr">
                        <span>收起</span>
                        <span class="hide">展开</span>
                        <span class="icon-rack icon-rack_small fr"></span>
                    </span>
                </div>
                <div class="sear_conL_searCond_bot">
                    <div class="sear_conL_searCond_bot1">
                        <span class="fl">搜索范围：</span>
                        <div id="sear_scope">
                        </div>
                        <span class="sear_conL_searCond_botMore fr">更多</span>
                    </div>
                </div>
                <div class="sear_conL_searCond_bot">
                    <div class="sear_conL_searCond_bot1">
                        <span class="fl">行业类别：</span>
                        <div id="sear_trade">
                        </div>
                        <span class="sear_conL_searCond_botMore fr">更多</span>
                    </div>
                </div>
                <div class="sear_conL_searCond_bot">
                    <div class="sear_conL_searCond_bot1">
                        <span class="fl">地理位置：</span>
                        <div id="sear_position">
                        </div>
                        <span class="sear_conL_searCond_botMore fr">更多</span>
                    </div>
                </div>
                <div class="sear_conL_searCond_bot">
                    <div class="sear_conL_searCond_bot1">
                        <span class="fl">企业状态：</span>
                        <div id="sear_compstate">
                        </div>
                        <span class="sear_conL_searCond_botMore hide fr">更多</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="sear_conL_list">
            <div class="sear_conL_listF">
                <div class="sear_conL_listFL sear_conL_active fl">
                    <span class="icon-seaCon icon-qiye fl"></span>
                    <span class="fl">企业</span>
                </div>
                <div class="sear_conL_listFL fl">
                    <span class="icon-seaCon icon-anjian fl"></span>
                    <span class="fl">案件</span>
                </div>
                <input type="hidden" id="search_type" value="1">
            </div>
            <div class="sear_conL_listS clear" id="sear_conL_listConQ"></div>
            <div class="sear_conL_listS clear hide" id="sear_conL_listConA"></div>
        </div>
    </div>
    <div class="sear_con_right fl">
        <div class="sear_locDis">
            <p class="title"><span class="fl">位置分布</span><span class="sear_right_tit fr">全国惩戒数量分布</span></p>
            <div class="sear_loc" id="cityRisk">
            </div>
        </div>
        <div class="focus_ranking">
            <p class="title"><span class="fl">实时更新</span><span class="sear_right_tit fr">全国惩戒实时数据更新</span></p>
            <div class="focus_rankcont">
                <ul id="focus_rankcont">
                </ul>
            </div>
        </div>
        <div class="focus_ranking">
            <p class="title"><span class="fl">发展趋势</span><span class="sear_right_tit fr">全国惩戒发展态势</span></p>
            <div class="sear_devTre" id="sear_devTre">
                <img src="${BASE_PATH}static/img/rack_chejie.jpg">
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>


<div class="g_coun_foot">
    <div class="g-coun_borBott">
        <div class="g_coun_f_main">
            <div class="g_coun_f_m_top clearfix">
                <div class="g_coun_f_m_t_l fl">
                    <h2 class="g_coun_f_m_t_title fl">企业风险</h2>
                    <ul class="g_coun_f_m_t_list fl">
                        <li>关于我们</li>
                        <li>免责声明</li>
                        <li>服务协议</li>
                        <li>权利通知</li>
                        <li>意见反馈</li>
                        <li>数据服务</li>
                        <li>常见问题</li>
                        <li> 版权声明</li>
                    </ul>
                </div>
                <div class="g_coun_f_m_t_c fl">
                    <h2 class="g_coun_f_m_t_title">联系我们</h2>

                    <p>企业邮箱：xxxxxx@xxxxx.com</p>

                    <p>客服电话：888888888</p>
                </div>
                <div class="g_coun_f_m_t_r fr">
                    <div class="fl g_coun_f_m_t_r_l">
                        <p class="g_coun_f_m_t_r_l_title">微信公众号</p>

                        <p class="g_coun_f_m_t_r_l_pic"></p>
                    </div>
                    <div class="fl g_coun_f_m_t_r_l">
                        <p class="g_coun_f_m_t_r_l_title">征信查APP</p>

                        <p class="g_coun_f_m_t_r_l_pic"></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="g-coun_borTop">
        <div class="g_coun_f_main">
            <div class="g_coun_f_m_bottom">
                <p>版权所有：xxxxxxxxx@2016 JINDIDATA 京ICP备 xxxxxxx</p>

                <p>京公网安备 11010802021795号</p>
            </div>
        </div>
    </div>
</div>
</body>
<script src="${BASE_PATH}static/js/jquery-1.10.2.min.js"></script>
<script src="${BASE_PATH}static/js/echarts.min.js"></script>
<script src="${BASE_PATH}static/js/china.js"></script>
<script>
    $(function () {
        cityData();//全国惩戒实时数据更新
        searchX(1);//默认查询项
        cityRiskData();//全国惩戒数量分布

        $(".sear_conL_listFL").click(function () {//企业信息、案件信息切换事件
            var index = $(this).index();
            $(this).addClass("sear_conL_active");
            $(this).siblings("div.sear_conL_listFL").removeClass("sear_conL_active");
            $(".sear_conL_listS").eq(index).removeClass("hide");
            $(".sear_conL_listS").eq(index).siblings("div.sear_conL_listS").addClass("hide");
            $("#search_type").val(index + 1);
            searchX(1);
        })
        $(".sear_conL_searCond_bot1").on("click", "li", function () {//搜索条件信息点击事件
            $(this).addClass("sear_conL_searCond_botAll");
            $(this).siblings("li").removeClass("sear_conL_searCond_botAll");
            $(this).parent().prev("span").removeClass("sear_conL_searCond_botAll");
            searchX(1);
        })
        $(".sear_conL_searCond_bot1").on("click", ".sear_all", function () {//搜索条件信息-全部-点击事件
            $(this).addClass("sear_conL_searCond_botAll");
            $(this).siblings("ul").find("li").removeClass("sear_conL_searCond_botAll");
            searchX(1);
        })
        $(".sear_conL_searCond_titR").click(function () {//智能搜索收起隐藏事件
            $(this).find("span").eq(0).toggleClass("hide");
            $(this).find("span").eq(1).toggleClass("hide");
            $(this).find("span").eq(2).toggleClass("icon-rack_small").toggleClass("icon-rack_more");
            $(this).parent().siblings("div.sear_conL_searCond_bot").toggleClass("hide");
        })
        $(".sear_conL_searCond_botMore").click(function () {//智能搜索项更多隐藏事件
            $(this).siblings("div").find("ul").toggleClass("riskHeigh26");
            if ($(this).text() != "更多") {
                $(this).text("更多");
            } else {
                $(this).text("隐藏");
            }
        })
    })

    function searHtmlFun(a, b) {
        var html = '';
        if (a) {
            html = '<span class="sear_all sear_conL_searCond_botAll fl"><span>全部</span></span>';
        } else {
            html = '<span class="sear_all fl"><span>全部</span></span>';
        }
        html += b;
        return html;
    }

    function searchX(order) {
        var searchUrl = '${BASE_PATH}risk/search';//搜索接口
        var stitle = $("#sear_conL_searInpTex").val(); //查询内容
        var pageNo = order; //查询第几页数
        var pageSize = 8; //每页显示记录数
        var scope = ""; //搜索范围
        var trade = "";//行业类别
        var position = "";//地理位置
        var compstate = "";//企业状态
        if ($("#sear_scope").find("li").hasClass("sear_conL_searCond_botAll")) {
            scope = $("#sear_scope").find("li.sear_conL_searCond_botAll").find("span").eq(0).text();
        }
        if ($("#sear_trade").find("li").hasClass("sear_conL_searCond_botAll")) {
            trade = $("#sear_trade").find("li.sear_conL_searCond_botAll").find("span").eq(0).text();
        }
        if ($("#sear_position").find("li").hasClass("sear_conL_searCond_botAll")) {
            position = $("#sear_position").find("li.sear_conL_searCond_botAll").find("span").eq(0).text();
        }
        if ($("#sear_compstate").find("li").hasClass("sear_conL_searCond_botAll")) {
            compstate = $("#sear_compstate").find("li.sear_conL_searCond_botAll").find("span").eq(0).text();
        }
        var type = $("#search_type").val(); //结果类型1 查询企业  2查询案件
        var data = {
            stitle: stitle,
            pageNo: pageNo,
            pageSize: pageSize,
            scope: scope,
            trade: trade,
            position: position,
            compstate: compstate,
            type: type
        };
        $.ajax({
            url: searchUrl,
            type: 'post',
            data: data,
            dataType: 'json',
            success: function (data) {
                if (data.code == -1) {
                    alert("查询失败");
                    return;
                }
                //搜索条件
                if ($(".sear_conL_searCond").find(".sear_conL_searCond_bot2").eq(0).hasClass("riskHeigh26") || scope == "") {
                    var scopeS = '<ul class="sear_conL_searCond_bot2 riskHeigh26 fl">';//搜索范围
                    $(".sear_conL_searCond").find(".sear_conL_searCond_botMore").eq(0).text("更多");
                } else {
                    var scopeS = '<ul class="sear_conL_searCond_bot2 fl">';//搜索范围
                }
                if ($(".sear_conL_searCond").find(".sear_conL_searCond_bot2").eq(1).hasClass("riskHeigh26") || trade == "") {
                    var tradeS = '<ul class="sear_conL_searCond_bot2 riskHeigh26 fl">';//行业类别
                    $(".sear_conL_searCond").find(".sear_conL_searCond_botMore").eq(1).text("更多");
                } else {
                    var tradeS = '<ul class="sear_conL_searCond_bot2 fl">';//行业类别
                }
                if ($(".sear_conL_searCond").find(".sear_conL_searCond_bot2").eq(2).hasClass("riskHeigh26") || position == "") {
                    var positionS = '<ul class="sear_conL_searCond_bot2 riskHeigh26 fl">';//地理位置
                    $(".sear_conL_searCond").find(".sear_conL_searCond_botMore").eq(2).text("更多");
                } else {
                    var positionS = '<ul class="sear_conL_searCond_bot2 fl">';//地理位置
                }
                if ($(".sear_conL_searCond").find(".sear_conL_searCond_bot2").eq(3).hasClass("riskHeigh26") || compstate == "") {
                    var compstateS = '<ul class="sear_conL_searCond_bot2 riskHeigh26 fl">';//企业状态
                } else {
                    var compstateS = '<ul class="sear_conL_searCond_bot2 fl">';//企业状态
                }
                var scopeA = true, tradeA = true, positionA = true, compstateA = true;
                $.each(data.scope, function (ii, iitem) {
                    if (iitem.name == scope && scope != "") {
                        scopeA = false;
                        scopeS += '<li class="sear_conL_searCond_botAll"><span>' + iitem.name + '</span></li>';
                    } else {
                        scopeS += '<li><span>' + iitem.name + '</span></li>';
                    }
                })
                $.each(data.trade, function (j, jtem) {
                    if (jtem.name == trade && trade != "") {
                        tradeA = false;
                        tradeS += '<li class="sear_conL_searCond_botAll"><span>' + jtem.name + '</span><span>（' + jtem.num + '）</span></li>';
                    } else {
                        tradeS += '<li><span>' + jtem.name + '</span><span>（' + jtem.num + '）</span></li>';
                    }
                })
                $.each(data.position, function (k, ktem) {
                    if (ktem.name == position && position != "") {
                        positionA = false;
                        positionS += '<li class="sear_conL_searCond_botAll"><span>' + ktem.name + '</span><span>（' + ktem.num + '）</span></li>';
                    } else {
                        positionS += '<li><span>' + ktem.name + '</span><span>（' + ktem.num + '）</span></li>';
                    }
                })
                $.each(data.compstate, function (t, ttem) {
                    if (ttem.name == compstate && compstate != "") {
                        compstateA = false;
                        compstateS += '<li class="sear_conL_searCond_botAll"><span>' + ttem.name + '</span><span>（' + ttem.num + '）</span></li>';
                    } else {
                        compstateS += '<li><span>' + ttem.name + '</span><span>（' + ttem.num + '）</span></li>';
                    }
                })
                scopeS += '</ul>';
                tradeS += '</ul>';
                positionS += '</ul>';
                compstateS += '</ul>';
                scopeS = searHtmlFun(scopeA, scopeS);
                tradeS = searHtmlFun(tradeA, tradeS);
                positionS = searHtmlFun(positionA, positionS);
                compstateS = searHtmlFun(compstateA, compstateS);
                $("#sear_scope").html(scopeS);//搜索范围
                $("#sear_trade").html(tradeS);//行业类别
                $("#sear_position").html(positionS);//地理位置
                $("#sear_compstate").html(compstateS);//企业状态
                //查询到的条目数量以及用时
                var html = "";
                if (type == 1) {
                    html +=//企业
                            '<div class="sear_conL_listS_time">' +
                            '	<span class="">为您查到与"</span>' +
                            '	<span class="colRed">' + stitle + '</span>' +
                            '	<span>"符合的企业数量</span>' +
                            '	<span class="colRed">' + data.totalRow + '</span>' +
                            '	<span>家，用时</span>' +
                            '	<span class="colRed">' + data.sec + '</span>' +
                            '	<span>秒</span>' +
                            '</div>';
                } else {
                    html +=//案件
                            '<div class="sear_conL_listS_time">' +
                            '	<span class="">为您查到与"</span>' +
                            '	<span class="colRed">' + stitle + '</span>' +
                            '	<span>"相关信息</span>' +
                            '	<span class="colRed">' + data.totalRow + '</span>' +
                            '	<span>条，用时</span>' +
                            '	<span class="colRed">' + data.sec + '</span>' +
                            '	<span>秒</span>' +
                            '</div>';
                }
                $.each(data.data, function (i, item) {
                    var risk = "";
                    if (item.risk == 1) {
                        risk = '低';
                    } else if (item.risk == 2) {
                        risk = '较低';
                    } else if (item.risk == 3) {
                        risk = '较高';
                    } else if (item.risk == 4) {
                        risk = '高';
                    } else if (item.risk == 5) {
                        risk = '极高';
                    }
                    var type1 = '';
                    if (item.type == 1) {
                        type1 = "法院公告";
                    } else if (item.type == 2) {
                        type1 = "裁判文书";
                    } else if (item.type == 3) {
                        type1 = "失信人信息";
                    } else if (item.type == 4) {
                        type1 = "被执行人信息";
                    } else if (item.type == 5) {
                        type1 = "工商处罚";
                    } else if (item.type == 6) {
                        type1 = "税务处罚";
                    } else if (item.type == 7) {
                        type1 = "海关处罚";
                    } else if (item.type == 8) {
                        type1 = "财政处罚";
                    }
                    if (type == 1) {
                        html +=//企业
                                '<div class="sear_conL_listCon">' +
                                '	<p class="sear_conL_listCon_tit">' +
                                '		<input value="' + item.id + '" type="hidden">' +
                                '		<span class="fl"><a href="#" onclick="jumpHtml(' + item.id + ')">' + item.company + '</a></span>' +
                                '		<span class="fr">' +
                                '			<span class="fl sear_right_pun">处罚（<span class="colRed">' + item.num + '</span>）</span>' +
                                '			<span class="fl">风险指数（<span class="colRed">' + risk + '</span>）</span>' +
                                '		</span>' +
                                '	</p>' +
                                '	<div class="sear_conL_listCon_det">' +
                                '		<div class="fl">' +
                                '			<span class="fl">法定代表人：</span>' +
                                '			<span>' + item.corporation + '</span>' +
                                '		</div>' +
                                '		<div class="fl">' +
                                '			<span class="fl">成立年限：</span>' +
                                '			<span>' + item.setupyear + '年内</span>' +
                                '		</div>' +
                                '		<div class="fl">' +
                                '			<span class="fl">注册资本：</span>' +
                                '			<span>' + item.recapital + '万人民币</span>' +
                                '		</div>' +
                                '		<div class="fl">' +
                                '			<span class="fl">股份名称：</span>' +
                                '			<span>' + item.share + '</span>' +
                                '		</div>' +
                                '		<div class="fl">' +
                                '			<span class="fl">企业地址：</span>' +
                                '			<span>' + item.address + '</span>' +
                                '		</div>' +
                                '	</div>' +
                                '</div>';
                    } else {
                        html +=//案件
                                '<div class="sear_conL_listCon">' +
                                '	<div class="sear_conL_listConDet fl">' +
                                '		<p class="sear_conL_listCon_tit">' + item.title + '</p>' +
                                '		<div class="sear_conL_listCon_det">' +
                                '			<div class="fl">' +
                                '				<span class="fl">案件编号：</span>' +
                                '				<span>' + item.casenumber + '</span>' +
                                '			</div>' +
                                '			<div class="fl">' +
                                '				<span class="fl">执行法院：</span>' +
                                '				<span>' + item.court + '</span>' +
                                '			</div>' +
                                '			<div class="fl">' +
                                '				<span class="fl">裁判日期：</span>' +
                                '				<span>' + item.judgetime + '</span>' +
                                '			</div>' +
                                '		</div>' +
                                '	</div>' +
                                '	<span class="sear_conL_listCon_type fr">' + type1 + '</span>' +
                                '</div>';
                    }
                })
                html +=//分页
                        '<div class="sear_conL__page page clearfix">' +
                        '	<ul class="fl">';

                var page = Math.ceil(data.totalRow / data.pageSize);
                var currPageNo = data.pageNumber;
                var minPageNo = 1;
                var maxPageNo = page;
                if (!pageNo || pageNo == null || pageNo == "") {
                    pageNo = 1;
                } else if (pageNo > page) {
                    pageNo = page;
                }
                if (maxPageNo > 10) {
                    if (pageNo > 5) {
                        if (maxPageNo - pageNo <= 4) {
                            minPageNo = maxPageNo - 9;
                        } else {
                            minPageNo = pageNo - 5;
                            maxPageNo = pageNo + 4;
                        }
                    } else {
                        maxPageNo = 10;
                    }
                }
                for (var int = 1; int <= page; int++) {
                    // 获取页码和当前页码
                    if (data.pageNumber == int) {
                        html += "<li class='page_action'>" + int + "</li>";
                    } else {
                        if (int >= minPageNo && int <= maxPageNo) {
                            html += "<li onclick='searchX(" + int + ")'>" + int + "</li>";
                        }
                    }
                }
                // 判断是否是第一页
                if (data.pageNumber != 1) {
                    html += "<li onclick='searchX(" + (data.pageNumber - 1) + ")'>&lt;</li>";
                }
                // 页数是否已加载完成
                // 判断是否是最后一页
                if (data.pageNumber != page) {
                    html += "<li onclick='searchX(" + (parseInt(data.pageNumber) + 1) + ")'>&gt;</li>";
                }
                html +=//
                        '	</ul>' +
                        '	<p class="fr page_all">共&nbsp;<span class="page_num">' + data.totalRow + '</span>&nbsp;条记录</p>' +
                        '</div>';
                if (type == 1) {
                    $("#sear_conL_listConQ").html(html);
                } else {
                    $("#sear_conL_listConA").html(html);
                }
            }
        })
    }

    //全国惩戒实时数据更新
    function cityData() {
        var cityUrl = '${BASE_PATH}risk/punishDataFeed';//全国惩戒实时数据更新接口
        $.ajax({
            url: cityUrl,
            type: 'post',
            dataType: 'json',
            success: function (data) {
                var rankcontHtml = "";
                $.each(data.data, function (k, ktem) {
                    var kk = parseInt(k) + 1;
                    if (k < 3) {
                        rankcontHtml += '<li><span class="mboer fl">' + kk + '</span><p class="conp fl"><a href="#">' + ktem.title + '</a></p><p class="conp2"><b>' + ktem.number + '</b>篇</p></li>';
                    } else {
                        rankcontHtml += '<li><span class="fl">' + kk + '</span><p class="conp fl"><a href="#">' + ktem.title + '</a></p><p class="conp2"><b>' + ktem.number + '</b>篇</p></li>';
                    }
                })
                $("#focus_rankcont").html(rankcontHtml);
            }
        })
    }
    //页面跳转
    function jumpHtml(id) {
        <%--window.location.href='${BASE_PATH}searchDetail.jsp';--%>
        window.location.href = 'searchDetail.jsp?id=' + id;
        sessionStorage.setItem("company_id", id);
    }

    //全国惩戒数量分布
    function cityRiskData() {
        var myChart = echarts.init(document.getElementById('cityRisk'));

        var cityRiskUrl = '${BASE_PATH}risk/punishDistribution';//全国惩戒数量分布接口
        $.ajax({
            url: cityRiskUrl,
            type: 'post',
            dataType: 'json',
            success: function (data) {
                var cityR = [];
                $.each(data.data, function (i, item) {
                    var json1 = {};
                    json1.name = item.name;
                    json1.value = item.number;
                    cityR.push(json1);
                })
                myChart.setOption({
                    tooltip: {
                        trigger: 'item'
                    },
                    visualMap: {
                        left: 'left',
                        itemWidth: '15',
                        itemHeight: '80',
                        text: ['高', '低']// 文本，默认为数值文本
                    },
                    series: [
                        {
                            name: '全国地理区域处罚统计',
                            type: 'map',
                            map: 'china',
                            mapType: 'china',
                            left: '10',
                            right: '10',
                            top: '20',
                            roam: false,
                            label: {
                                normal: {
                                    show: false
                                },
                                emphasis: {
                                    show: true,
                                    textStyle: {
                                        fontSize: 12
                                    }
                                }
                            },
                            data: cityR
                        }
                    ]
                });
            }
        })
    }
</script>
</html>